package com.yy.web.pm.advertisementRemove.service.Impl;

import com.yy.web.pm.advertisementRemove.Dto.RemoveDto;
import com.yy.web.pm.advertisementRemove.mapper.TestMapper;
import com.yy.web.pm.user.domain.User;
import com.yy.web.pm.user.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
import java.util.List;
import com.yy.web.pm.advertisementRemove.mapper.AdvertisementRemoveMapper;
import com.yy.web.pm.advertisementRemove.domain.AdvertisementRemove;
import com.yy.web.pm.advertisementRemove.service.AdvertisementRemoveService;

import static com.yy.web.pm.alarm.service.Impl.AlarmDateServiceImpl.extractOpenId;

@Service
public class AdvertisementRemoveServiceImpl implements AdvertisementRemoveService{

    @Autowired
    private AdvertisementRemoveMapper advertisementRemoveMapper;
    @Autowired
    private UserMapper userMapper;
    @Autowired
    private TestMapper testMapper;
    @Override
    public int deleteByPrimaryKey(Integer id) {
        return advertisementRemoveMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(AdvertisementRemove record) {
        return advertisementRemoveMapper.insert(record);
    }

    @Override
    public int insertSelective(AdvertisementRemove record) {
        return advertisementRemoveMapper.insertSelective(record);
    }

    @Override
    public AdvertisementRemove selectByPrimaryKey(Integer id) {
        return advertisementRemoveMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(AdvertisementRemove record) {
        return advertisementRemoveMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(AdvertisementRemove record) {
        return advertisementRemoveMapper.updateByPrimaryKey(record);
    }

    @Override
    public int updateBatch(List<AdvertisementRemove> list) {
        return advertisementRemoveMapper.updateBatch(list);
    }

    @Override
    public int batchInsert(List<AdvertisementRemove> list) {
        return advertisementRemoveMapper.batchInsert(list);
    }

    @Override
    public List<RemoveDto> selectAllList1(RemoveDto removeDto) {
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        String openId = extractOpenId(authentication.getName());
        User user = userMapper.getUserByOpenId(openId);//获取当前用户信息
        removeDto.setUserId(String.valueOf(user.getId()));
        return testMapper.selectAllList1(removeDto);
    }


}
